package com.springboot.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.springboot.dao.UserDao;
import com.springboot.entity.UserEntity;

@RestController
public class IndexController {
	@Autowired
	private UserDao userDao;
	/**
	 * 使用spring-data-jpa查询数据
	 * @return
	 */
	@RequestMapping("/jpaFindUser")
	public Object jpaIndex() {
		//Optional<User> userOptional = userDao.findById(user.getId());
		UserEntity reusltUser =  userDao.findById(1).get();
		return reusltUser == null ? "没有查询到数据" : reusltUser;
	}

}

